/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Portions created by the Initial Developer are
 * Copyright (C) 2012 the Initial Developer.
 * All Rights Reserved.
 *
 * The Original Code is "http://semi-frame.googlecode.com/svn/trenk/".
 *
 * The Initial Developer of the Original Code is the author below.
 */
/**
 * @file LogPrinter.h
 * @brief auto generated.
 * @author mornongcloud
 * @date 2011/10/15
 */

#ifndef SEMILOGGLOGPRINTER_H_
#define SEMILOGGLOGPRINTER_H_

// #include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <sys/time.h>
#include "semi/util/StringUtil.h"
#include "semi/posix/Semaphore.h"

namespace semi {
namespace logg {

/*
 * @brief LogPrinter class.
 *
 */
class LogPrinter {
public:
	LogPrinter();
	virtual ~LogPrinter();

	//    void setLogSize(int size);
	void init(std::string path, int size = 50000);
	void logging(const char *pFormat, ...);

	void terminate();

	// @brief Log file path
	std::string file_path;

private:
	void print(std::string file_path, int file_size, const char *pFormat,
			va_list list);

	// @brief Max log size.
	int log_size;

	// @brief Semaphore for log files.
	semi::posix::Semaphore semaphore;

};

}
}

#endif /* SEMILOGGLOGPRINTER_H_ */
